"""
URL map for the Live application.
"""

from django.conf.urls.defaults import *
from django.conf import settings
from os import path

# Define regular expressions for vehicle and tag slugs
slugRegexp    = r'[a-zA-Z0-9_\-]+'
tagRegexp     = r'(?P<tag>'    + slugRegexp + r')'
vehicleRegexp = r'(?P<vehicle>' + slugRegexp + r')'

# Configuration for default views
from track.models import Vehicle

vehicle_dict = {
  'queryset':             Vehicle.objects.all(),
  'template_name':        'live/menu/vehicles.html',
  'template_object_name': 'vehicle'
}

from live.models import Tag
tag_dict = {
  'queryset':             Tag.objects.all(),
  'template_name':        'live/menu/tags.html',
  'template_object_name': 'tag'
}

urlpatterns = patterns('',
  (r'^$',      'live.views.live'),
  # Text based live interface
  (r'^text/$', 'live.views.index'),

  (r'^ajax/tags/$',        'live.ajax.tags'),
  (r'^ajax/vehicletags/$', 'live.ajax.vehicleTags'),
  
  (r'^menu/vehicles/$',    'django.views.generic.list_detail.object_list', vehicle_dict),
  (r'^menu/tags/$',        'django.views.generic.list_detail.object_list', tag_dict),

  (r'^demos/svg/$',         'django.views.generic.simple.direct_to_template', {'template': 'live/demos/svg.html'}),
  (r'^demos/image/$',       'django.views.generic.simple.direct_to_template', {'template': 'live/demos/image.html'}),
  (r'^demos/checkpoints/$', 'django.views.generic.simple.direct_to_template', {'template': 'live/demos/checkpoints.html'}),

  # Add and remove tags
  (r'^tag/new/(?P<tag>.+)/',          'live.tags.new'),
  (r'^tag/delete/' + tagRegexp + '/', 'live.tags.delete'),

  # Tag attributes manipulation
  (r'^tag/set/public/' + tagRegexp + r'/(?P<public>(True|False))/', 'live.tags.set_public'),

  # Tag association manipulation methods
  (r'^tag/add/' + tagRegexp + '/' + vehicleRegexp + '/',    'live.tags.add'),
  (r'^tag/remove/' + tagRegexp + '/' + vehicleRegexp + '/', 'live.tags.remove'),
  
  # User options manipulation
  (r'^options/load/$', 'live.ajax.loadOptions'),
  (r'^options/save/$', 'live.ajax.saveOptions'),
)
